package com.succodes.lostandfound.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.succodes.lostandfound.dto.PropertyAddEditParam;
import com.succodes.lostandfound.dto.PropertyQueryParam;
import com.succodes.lostandfound.service.IPropertyService;
import com.succodes.lostandfound.vo.PropertyVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 丢失的个人所有物，包括根据物品寻找失主和失主寻找失物 前端控制器
 * </p>
 *
 * @author 石炫杰
 * @since 2022-08-17
 */
@RestController
@RequestMapping("/property")
public class PropertyController {
    @Autowired
    private IPropertyService propertyService;
    @PostMapping(value = "")
    @ApiOperation(value = "发布寻物启事/失物招领", notes = "发布寻物启事/失物招领")
    public Boolean add(@RequestBody PropertyAddEditParam propertyAddEditParam){
        return propertyService.add(propertyAddEditParam);
    }

    @PostMapping(value = "/app/page")
    @ApiOperation(value = "【查询】通过条件分页查询APP失物列表", notes = "通过条件查询APP失物列表", response = PropertyVo.class)
    public Page<PropertyVo> appPage(@Validated @RequestBody PropertyQueryParam propertyQueryParam){
        return propertyService.appPage(propertyQueryParam);
    }

    @PostMapping(value = "/app/detail")
    @ApiOperation(value = "根据id查询失物详情信息")
    public PropertyVo detail(@RequestParam Long propertyId){
        return propertyService.detail(propertyId);
    }
}
